<?php if($assigned_teacher){?>
    <?php
    echo $assigned_teacher['f_name'].' '.$assigned_teacher['l_name']?>
<?php }?>

<?php if($assign_stat != LinkTeacherProgramTable::STATUS_APPROVED){?>
<a href="#" onclick="$(this).fadeOut('fast', function(){ $(this).parent().find('.assign_list').fadeIn(); }); return false;">
    <?php if($assigned_teacher){?>
        <?php echo '<br/>'.__('Edit Assignment')?>
    <?php }else{ ?>
        <?php echo __('Assign')?>   
    <?php } ?>
</a>
<div class="assign_list" style="display: none;">
    <form id="assign_frm_<?php echo $program_id.$assign_index ?>" action="<?php echo url_for('assignment/ajaxAssign?program_id='.$program_id.'&school_intg_id='.$school_intg_id);?>" method="post" onsubmit="submit_ajax_form('assign_frm_<?php echo $program_id.$assign_index ?>', 'assign_cont_<?php echo $program_id.$assign_index ?>'); add_download_button(<?php echo $program_id ?>,<?php echo $assign_index ?>) ;return false;">
    <select name="teacher_to_assign" id="teacher_ddl_<?php echo $program_id.$assign_index ?>">
        <option value="" >&nbsp;</option>
        <?php foreach($teachers as $teacher){?>
            <option value="<?php echo $teacher['intg_identity']?>" <?php if($teacher['intg_identity'] == $assigned_teacher['intg_identity']){ echo "selected='selected'"; }?>>
                <?php echo $teacher?>
            </option>
        <?php }?>
    </select>
        <input type="hidden" value="<?php echo $assigned_teacher ? $assigned_teacher['intg_identity'] : '' ?>" name="old_assigned_teacher"/>
        <input type="hidden" value="<?php echo $assign_index ? $assign_index : '' ?>" name="assign_index"/>
    <input type="submit" value="<?php echo __('Assign')?>" />
    </form>
</div>
<?php }?>

<script>
    download_href = '<?php echo url_for("assignment/downloadApproval") ?>';

    function add_download_button(pid, aid){
        teacher_id = jQuery('select#teacher_ddl_'+pid+aid).val();
        jQuery('td[program_id='+pid+aid+']').html('<a href="'+download_href+'?program_id='+pid+'&teacher_id='+teacher_id+'"><?php echo __('Download Approval Document') ?></a>');
        jQuery('td[program_id='+pid+aid+']').parent().removeClass('row_status_0').addClass('row_status_1');
    }
</script>